package com.sdhs.projectschedule.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.projectschedule.domain.GcProgressHandIn;
import com.sdhs.projectschedule.service.IGcProgressHandInService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 项目进度控制--项目交工Controller
 *
 * @author andong
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/progress/handIn")
public class GcProgressHandInController extends BaseController
{
    @Autowired
    private IGcProgressHandInService gcProgressHandInService;

    /**
     * 查询项目进度控制--项目交工列表
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcProgressHandIn gcProgressHandIn)
    {
        startPage();
        List<GcProgressHandIn> list = gcProgressHandInService.selectGcProgressHandInList(gcProgressHandIn);
        return getDataTable(list);
    }

    /**
     * 导出项目进度控制--项目交工列表
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:export')")
    @Log(title = "项目进度控制--项目交工", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcProgressHandIn gcProgressHandIn)
    {
        List<GcProgressHandIn> list = gcProgressHandInService.selectGcProgressHandInList(gcProgressHandIn);
        ExcelUtil<GcProgressHandIn> util = new ExcelUtil<GcProgressHandIn>(GcProgressHandIn.class);
        util.exportExcel(response, list, "项目进度控制--项目交工数据");
    }

    /**
     * 获取项目进度控制--项目交工详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcProgressHandInService.selectGcProgressHandInById(id));
    }

    /**
     * 新增项目进度控制--项目交工
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:add')")
    @Log(title = "项目进度控制--项目交工", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcProgressHandIn gcProgressHandIn)
    {
        return success(gcProgressHandInService.insertGcProgressHandIn(gcProgressHandIn));
    }

    /**
     * 修改项目进度控制--项目交工
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:edit')")
    @Log(title = "项目进度控制--项目交工", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcProgressHandIn gcProgressHandIn)
    {
        return toAjax(gcProgressHandInService.updateGcProgressHandIn(gcProgressHandIn));
    }

    /**
     * 项目进入缺陷责任期
     */
   /* @PreAuthorize("@ss.hasPermi('projectschedule:handIn:period')")*/
    @Log(title = "项目进度控制--项目进入缺陷责任期", businessType = BusinessType.UPDATE)
    @PutMapping("/period")
    public AjaxResult updatePeriod(@RequestBody GcProgressHandIn gcProgressHandIn)
    {
        return toAjax(gcProgressHandInService.updatePeriod(gcProgressHandIn));
    }

    /**
     * 删除项目进度控制--项目交工
     */
    @PreAuthorize("@ss.hasPermi('projectschedule:handIn:remove')")
    @Log(title = "项目进度控制--项目交工", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(gcProgressHandInService.deleteGcProgressHandInById(id));
    }
}
